<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>商品列表</title>
    <!-- 引入Bootstrap CSS -->
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="js/vue.min.js">
    <!-- 自定义样式 -->
    <style>
        body {
            background-color: #f8f9fa;
        }

        .product-card {
            border: none;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s ease-in-out;
        }

        .product-card:hover {
            transform: translateY(-5px);
        }

        .product-name {
            text-align: center;
            font-size: 1.25rem;
            font-weight: bold;
            color: #343a40;
			
			overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 1; /* 显示的最大行数 */
            -webkit-box-orient: vertical;
        }

        .product-price {
            font-size: 1.125rem;
            color: #dc3545;
        }

        .product-description {
            font-size: 0.9375rem;
            color: #6c757d;
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 2; /* 显示的最大行数 */
            -webkit-box-orient: vertical;
        }

        .add-to-cart-button,
        .buy-now-button {
            background-color: #007bff;
            color: white;
            font-weight: bold;
        }

        .add-to-cart-button:hover,
        .buy-now-button:hover {
            background-color: #0056b3;
            color: white;
        }
        .product-card img{
            width: 200px;
            height: 200px;
            display: block;
            margin:5px auto;
        }
    </style>
</head>
<body>
<div class="container my-5">
    <!-- 搜索栏 -->
    <div class="mb-4">
        <form class="d-flex" action="/goods/search" method="get">
            <input class="form-control me-2" value="${searchVal}" name="searchVal" type="search" placeholder="搜索商品" aria-label="Search">
            <button class="btn btn-primary" type="submit">搜索</button>
        </form>
    </div>

    <h1 class="text-center mb-4">商品列表</h1>
    <div class="row row-cols-1 row-cols-md-3 g-4">



        <!-- 商品卡片 -->
        <c:forEach items="${goodsList}" var="goods">



        <div class="col">
            <div class="card product-card" >
                <img src="${goods.pic}" alt="乐易【2024新款升级版】大屏幕手机" >
                <div class="card-body">
                    <h5 class="card-title product-name">
                        <a href="javascript:">${goods.name}</a>
                    </h5>
                    <p class="card-text product-description">${goods.title}</p>
                    <p class="card-text product-price"><small class="text-muted">价格:</small> ${goods.price}元</p>
                    <div class="d-grid gap-2">
                        <a href="#" class="btn add-to-cart-button">加入购物车</a>
                        <a href="#" class="btn buy-now-button">立即下单</a>
                    </div>
                </div>
            </div>
        </div>
        </c:forEach>

    </div>
</div>

<!-- 引入Bootstrap JS -->
<script src="/js/bootstrap.bundle.min.js"></script>
</body>

<script>

</script>
</html>